<template>
    <div class="edit_container">
        <div class="btn_box">
            <el-button @click.stop="goBack">返回</el-button>
        </div>
        <Degree ref="degree" form-type="view" :patient-info="patientInfo" :assess-info="assessInfo"
            :doctor-type="doctorType" />
    </div>
</template>

<script>
import Degree from '../../assessSys/components/degree.vue'
import { perceiveDegreeDetail } from '@/api/treatment/treatment.js'
import moment from 'moment'

export default {
    name: 'DegreeView',
    components: { Degree },
    data() {
        return {
            assessId: 0,
            type: 0,
            source: 1,
            patientInfo: {},
            assessInfo: {}
        }
    },
    computed: {
        doctorType() {
            const sourceMap = {
                1: 'hospital',
                2: 'outpatient',
                3: 'therapists'
            }
            return sourceMap[this.source]
        }
    },
    mounted() {
        this.type = this.$route.query.type || 0
        this.source = this.$route.query.source
        this.assessId = this.$route.query.id
        this.getAssessInfo()
    },
    methods: {
        getAssessInfo(assessId) {
            // 执行获取治疗详情
            perceiveDegreeDetail({
                type: this.type,
                evaluateSource: this.source,
                relationId: this.assessId
            }).then(res => {
                this.patientInfo = {
                    ...res.content
                }
                if (res.content.evaluateTime) {
                    res.content.evaluateTime = moment(res.content.evaluateTime).format('YYYY-MM-DD HH:mm:ss')
                }
                this.assessInfo = {
                    ...this.assessInfo,
                    ...res.content
                }
            })
        },
        goBack() {
            this.$store.dispatch('tagsView/delView', this.$route)
            this.$router.back()
        }
    }
}
</script>

<style lang="scss" scoped>
@import url('./style.scss');
</style>
